Open
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #6
This commit restores the Bun macro functionality in models.ts by adding
the `with { type: "macro" }` directive to the import statement.
Key changes:
- Added macro directive to models-macro import in src/provider/models.ts
- Created comprehensive documentation in docs/MACRO_SUPPORT.md
How it works:
- Macros work in development mode (running from source)
- Macros gracefully fallback when running from node_modules
- Runtime fetching is used when macros are unavailable
Limitations:
Due to Bun's security model, macros cannot execute from node_modules.
This means macros only work when running from source, not when
installed globally via `bun install -g`. The code handles this
gracefully with automatic fallback to runtime fetching.
Alternative approaches considered:
1. Pre-bundling: Async macros caused bundler to hang
2. Bundled JSON: Would add ~600KB to package size
The current solution provides the best balance:
- Development performance optimization through macros
- Reliable production behavior through runtime fetching
- No user configuration required
Related: #6
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This reverts commit 99daa5a.
Contributor
Author
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
Contributor
Author
🔄 Auto-restart 1/3Detected uncommitted changes from previous run. Starting new session to review and commit them. Uncommitted files: Auto-restart will stop after changes are committed or after 2 more iterations. Please wait until working session will end and give your feedback. |
This commit adds development tooling to demonstrate and verify the macro functionality works as expected: 1. experiments/test-macro.ts - Verifies the macro imports and executes correctly in development mode, fetching ~596KB JSON from models.dev 2. experiments/test-agent-simple.sh - Tests that the agent runs correctly with macro support enabled 3. scripts/build.ts - Experimental build script that attempts to bundle the application with macros evaluated at build time (investigation showed async macros with network fetching cause bundler to hang) These scripts provide evidence that the macro restoration works in development mode and document the pre-bundling investigation. Related: #6 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR restores Bun macro support for the models.dev data fetching functionality, as requested in issue #6. The implementation adds the macro directive while maintaining backward compatibility through automatic fallback.
Key Changes
Restored macro directive in
src/provider/models.ts:Added comprehensive documentation in
docs/MACRO_SUPPORT.mdexplaining:How It Works
Limitations
Due to Bun's security model, macros cannot execute from
node_modules. This is a fundamental restriction documented in the official Bun macro documentation:This means:
bun install -g)Testing
The macro has been tested and verified to work in development mode:
The existing test suite continues to pass, confirming backward compatibility.
Alternative Approaches Investigated
Pre-bundling with
bun build:Bundling cached JSON:
Conclusion
This implementation provides the best of both worlds:
While macros cannot work in globally-installed packages due to Bun's security model, restoring the macro directive enables development-time optimizations and keeps the door open for future improvements if Bun adds support for pre-compiled/bundled packages.
Fixes #6
🤖 Generated with Claude Code